<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../template/AdminTemplate.xhtml">

    <ui:define name="contentInsert">

        <h3>Create New Tier</h3>
        <h:form>
          
 
                <h:panelGrid columns="3">
                    <h:outputLabel for="name" style="font-weight: bold" value="Tier Name: " />
                    <h:inputText required="true" label="Tier Name" requiredMessage="Tier Name is required." id="name" value="#{tierManagerBean.name}">
                    </h:inputText>
                    <p:message for="name" />
                    <h:outputLabel for="commissionPercent" style="font-weight: bold" value="Commission Percentage: " />
                    <h:inputText required="true" label="Commission Percentage" requiredMessage="Commission Percentage is required." id="commissionPercent" value="#{tierManagerBean.commissionPercent}">                        
                    </h:inputText>
                    <p:message for="commissionPercent" />
                    <h:outputLabel for="feeSubscription" style="font-weight: bold" value="Fee subcription: " />
                    <h:inputText required="true" label="Fee subcription" requiredMessage="Subscription Fee is required." id="feeSubscription" value="#{tierManagerBean.feeSubscription}">

                    </h:inputText>
                    <p:message for="feeSubscription" />
                    <h:outputLabel for="feeMarketIntelligence" style="font-weight: bold" value="Market Intelligenge Fee: " />
                    <h:inputText required="true" label="Market Intelligenge Fee" requiredMessage="Market Intelligenge Fee is required." id="feeMarketIntelligence" value="#{tierManagerBean.feeMarketIntelligence}">

                    </h:inputText>
                    <p:message for="feeMarketIntelligence" />
                    <h:outputLabel for="costPerClick" style="font-weight: bold" value="Cost Per Click: " />
                    <h:inputText required="true" label="Cost Per Click" requiredMessage="Cost Per Click is required." id="costPerClick" value="#{tierManagerBean.costPerClick}">

                    </h:inputText>
                    <p:message for="costPerClick" />
                </h:panelGrid>
                <h:commandButton id="btn" value="Create New Tier" onclick="if (!confirm('Are you sure you want to create new tier?')) return false"
                                 action="#{tierManagerBean.createNewTier(event)}"
                                 />

           
        </h:form>
        <h3>Delete Tier</h3>
     
       
            
            <h:form> 
                <p:dataTable value="#{tierManagerBean.allTiers}" var="o" paginator="true" rows="15"
                             styleClass="order-table" style="font-size: 10px"

                             >

                    <p:column>

                        <f:facet name="header">Tier Name</f:facet>
                        #{o.name}

                    </p:column>

                    <p:column>

                        <f:facet name="header">Commission <br/> Percentage</f:facet>
                        #{o.commissionPercent}

                    </p:column>

                    <p:column>

                        <f:facet name="header">Subscription <br/> Fee</f:facet>
                        #{o.feeSubscription}

                    </p:column>

                    <p:column>

                        <f:facet name="header">Transaction Analytics<br/> Fee</f:facet>
                        #{o.feeMarketIntelligence}

                    </p:column>

                    <p:column>

                        <f:facet name="header">Advertisement <br/> Cost Per Click</f:facet>
                        #{o.costPerClick}

                    </p:column>    

                    <p:column>

                        <f:facet name="header">Action</f:facet>

                        <h:commandLink value="Delete" onclick="if (!confirm('Are you sure you want to delete #{o.name}?')) return false"
                                       action="#{tierManagerBean.deleteTier(o)}"
                                       />


                    </p:column>

                </p:dataTable>            
                <p:panel id="panel" >
                    <p:ajaxStatus style="width:16px;height:16px;">
                        <f:facet name="start">
                            <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                        </f:facet>
                        <f:facet name="complete">
                            <h:outputText value="" />
                        </f:facet>
                    </p:ajaxStatus>
                    <p:messages />
                </p:panel>
            </h:form>


    </ui:define>
</ui:composition>

